Repository navigation
[SM6.10] LinAlg Validation: MatVecMul MatVecMulAdd - #8718
Conversation
There was a problem hiding this comment.
Pull request overview
Adds SM 6.10 validation for DXIL matrix-vector multiply operations.
Changes:
- Validates matrix scope/use, dimensions, component interpretation, signed floating-point outputs, and bias compatibility.
- Adds focused validation tests and updates shader-stage fixtures.
- Registers and documents new diagnostics.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
utils/hct/hctdb.py |
Registers validation rules. |
tools/clang/test/LitDXILValidation/LinAlgMatrix/linalgmatrix-vs.ll |
Updates vertex-stage fixture. |
tools/clang/test/LitDXILValidation/LinAlgMatrix/linalgmatrix-raytracing.ll |
Updates ray-tracing fixtures. |
tools/clang/test/LitDXILValidation/LinAlgMatrix/linalgmatrix-ps.ll |
Updates pixel-stage fixture. |
tools/clang/test/LitDXILValidation/LinAlgMatrix/linalgmatrix-node.ll |
Updates node-stage fixture. |
tools/clang/test/LitDXILValidation/LinAlgMatrix/linalgmatrix-ms.ll |
Updates mesh-stage fixture. |
tools/clang/test/LitDXILValidation/LinAlgMatrix/linalgmatrix-matvecmuladd.ll |
Tests invalid multiply-add operations. |
tools/clang/test/LitDXILValidation/LinAlgMatrix/linalgmatrix-matvecmul.ll |
Tests invalid multiply operations. |
tools/clang/test/LitDXILValidation/LinAlgMatrix/linalgmatrix-hs.ll |
Updates hull-stage fixture. |
tools/clang/test/LitDXILValidation/LinAlgMatrix/linalgmatrix-gs.ll |
Updates geometry-stage fixture. |
tools/clang/test/LitDXILValidation/LinAlgMatrix/linalgmatrix-ds.ll |
Updates domain-stage fixture. |
tools/clang/test/LitDXILValidation/LinAlgMatrix/linalgmatrix-cs.ll |
Updates compute-stage fixture. |
tools/clang/test/LitDXILValidation/LinAlgMatrix/linalgmatrix-as.ll |
Updates amplification-stage fixture. |
tools/clang/test/CodeGenDXIL/hlsl/linalg/builtins/matrixvectormultiplyadd/nominal.hlsl |
Makes multiply-add codegen cases valid. |
tools/clang/test/CodeGenDXIL/hlsl/linalg/builtins/matrixvectormultiply/nominal.hlsl |
Makes multiply codegen cases valid. |
lib/DxilValidation/DxilValidationUtils.h |
Declares type formatting utility. |
lib/DxilValidation/DxilValidationUtils.cpp |
Implements type formatting utility. |
lib/DxilValidation/DxilValidation.cpp |
Implements operation validation. |
docs/DXIL.rst |
Documents diagnostics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated no new comments.
Suppressed comments (1)
lib/DxilValidation/DxilValidation.cpp:1147
- For packed interpretations this value is the required physical vector length, not the matrix K dimension. For example, the new
C21M4N8test reportsK dimension '2'even though its metadata declares K=8. This makes the diagnostic factually incorrect; either report both K and the packed vector length or rename the message to describe the required vector size.
CI, ValidationRule::InstrLinAlgMatrixDimVectorMismatch,
{"Input", std::to_string(InputVecTy->getNumElements()), "K",
std::to_string(K)});
470027a to
fa9a6fa
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated no new comments.
Suppressed comments (2)
lib/DxilValidation/DxilValidation.cpp:1141
- The K-dimension check still runs when the interpretation is nonconstant or rejected. In those cases
InterpisInvalid/unsupported andComponentTypeElementsPerScalarfalls through to4, so the validator can emit an arbitrary, misleading vector-size error in addition to the real interpretation error. Only compute/check K after the interpretation has been validated, or make the helper represent unsupported types explicitly.
unsigned ElementsPerScalar = ComponentTypeElementsPerScalar(Interp);
unsigned K = (MatLATT.N + ElementsPerScalar - 1) / ElementsPerScalar;
utils/hct/hctdb.py:8645
- This shared diagnostic is now also emitted for an invalid input-vector interpretation, where saying the type is disallowed “in LinAlg Matrix” is inaccurate and can send users looking at the matrix metadata instead of the interpretation operand. Please make the wording apply to both contexts (for example, “not allowed in this LinAlg operation”) and update the generated documentation/tests accordingly.
"Component Type '%0' not allowed in LinAlg Matrix.",
Finn Plummer (inbelic)
left a comment
There was a problem hiding this comment.
LGTM once comment is resolved
| default: | ||
| return 4; |
There was a problem hiding this comment.
Maybe worth listing out the elements here or a comment as it isn't immediately obvious why this would the case.
nit: Also I would expect LastEntry/Invalid should maybe be 0? Although it is presumably unreachable in any case
There was a problem hiding this comment.
The pattern of only listing out the native types was copied over from what we do in the linalg.h header (which this comment reminds me, I need to do BFloat16 = 2 here)
Happy to explictly list them and add a comment like 8bit => 4 elements
I think I'd rather asster on LastEntry/Invalid. IIRC ComponentTypeElementsPerScalar can be used as a divisor so 0 would be a really bad potential value
There was a problem hiding this comment.
Yep! 1141
unsigned K = (MatLATT.N + ElementsPerScalar - 1) / ElementsPerScalar;There was a problem hiding this comment.
Listing them and asserting otherwise sounds good to me
There was a problem hiding this comment.
Actually, I can't assert here because it'll crash the tests where we intentionally use invalid types to verify a validation error is raised. I think this we have the validation error it should be okay to add a comment along the lines of all other values are invalid and their usage is detected in other parts of the validator
| // CHECK-LABEL: define void @main() | ||
|
|
||
| __builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 5, 4, 1, 2)]] mat; | ||
| __builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 4, 4, 0, 0)]] mat; |
There was a problem hiding this comment.
Are these numbers changing to workaround something that now would trigger a validation error?
There was a problem hiding this comment.
yep!
| %5 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %1, %dx.types.ResourceProperties { i32 11, i32 0 }) ; AnnotateHandle(res,props) resource: ByteAddressBuffer | ||
| %6 = call %dx.types.LinAlgMatrixC9M4N8U0S2 @dx.op.linAlgMatrixLoadFromDescriptor.mC9M4N8U0S2(i32 -2147483634, %dx.types.Handle %5, i32 0, i32 0, i32 0, i32 0) ; LinAlgMatrixLoadFromDescriptor(handle,offset,stride,layout,align) | ||
|
|
||
| ; CHECK-NEXT: Function: main: error: Matrix Scope 'ThreadGroup' does not match expected scope Thread. |
There was a problem hiding this comment.
nit: Do you want to put single quotes around Thread in this diagnostic?
There was a problem hiding this comment.
The rule I've been following is that 'foo' means foo was a variable provided by the user while just foo means foo is a fixed requirement of the operation. I was trying to match what I say for other operations but I don't think we have a clear style guide here
| %8 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %1, %dx.types.ResourceProperties { i32 11, i32 0 }) ; AnnotateHandle(res,props) resource: ByteAddressBuffer | ||
| %9 = call %dx.types.LinAlgMatrixC9M4N8U1S0 @dx.op.linAlgMatrixLoadFromDescriptor.mC9M4N8U1S0(i32 -2147483634, %dx.types.Handle %8, i32 0, i32 0, i32 0, i32 0) ; LinAlgMatrixLoadFromDescriptor(handle,offset,stride,layout,align) | ||
|
|
||
| ; CHECK-NEXT: Function: main: error: Matrix Use 'B' does not match expected use A. |
There was a problem hiding this comment.
nit: Same single quote comment here.
fa9a6fa to
894e21f
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated no new comments.
Suppressed comments (2)
tools/clang/test/LitDXILValidation/LinAlgMatrix/linalgmatrix-cs.ll:36
- This newly added comment describes a 4x4 accumulator, but the declared
%dx.types.LinAlgMatrixC4M4N5U2S2and its target-type metadata both use M=4, N=5. Please keep the test documentation consistent with the actual matrix dimensions.
; Matrix<I32, 4, 4, Accumulator, ThreadGroup>
lib/DxilValidation/DxilValidation.cpp:1111
- This adds user-visible SM 6.10 validation behavior, but
docs/ReleaseNotes.mdhas no corresponding entry. Please add this MatVecMul/MatVecMulAdd validation work to the existing Experimental Shader Model 6.10 section, or point to the related PR that will provide the shared release-note coverage.
static void ValidateLinAlgMatVecMul(CallInst *CI, ValidationContext &ValCtx,
const char *OpName = "LinAlgMatVecMul") {
ValidateLinAlgOpParameters(CI, ValCtx);
Fixes #8503
Fixes #8504
Adds validation rules for MatVecMul and MatVecMulAdd DXIL operations